package com.donleo.stmg.relation.controller;


import com.donleo.stmg.common.api.CommonResult;
import com.donleo.stmg.relation.model.TeamChangeRecord;
import com.donleo.stmg.relation.service.TeamChangeRecordService;
import com.donleo.stmg.relation.vo.TeamChangeRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 换组记录表 前端控制器
 * </p>
 *
 * @author liangd
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/teamChangeRecord")
public class TeamChangeRecordController {

    @Autowired
    private TeamChangeRecordService teamChangeRecordService;

    @PreAuthorize("hasAuthority('method:team:read')")
    @GetMapping("/findAll")
    public CommonResult findAll(TeamChangeRecordVo teamChangeRecordVo){
        List<TeamChangeRecord> list = teamChangeRecordService.findAll(teamChangeRecordVo);
        long total = teamChangeRecordService.getCount(teamChangeRecordVo);
        return CommonResult.success(total,list);
    }

    @PreAuthorize("hasAuthority('method:team:delete')")
    @PostMapping("/deletes")
    public CommonResult deletes(Integer[] ids){
        List<Integer> idsList = Arrays.asList(ids);
        return teamChangeRecordService.deletes(idsList);
    }
}
